/*
 * Created by Storm Zhang, Feb 11, 2014.
 */

package com.guangzhi.weijianzhi.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.guangzhi.weijianzhi.R;
import com.guangzhi.weijianzhi.context.WeiJianZhiEntity;
import com.guangzhi.weijianzhi.http.HttpUrls;
import com.ihgoo.allinone.http.RequestManager;
import com.testin.agent.TestinAgent;

public class BaseActivity extends FragmentActivity{
	protected Activity activity;
	
	public Button goBack;
	public Button titleRightBtn;
	public Button titleRightBtn2;
	public TextView titleTextV;
	public RelativeLayout title;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE); 
//	     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,    
//	    	        WindowManager.LayoutParams.FLAG_FULLSCREEN); 
		activity = this;
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		TestinAgent.onResume(this);
	}
	@Override
	public void onStop() {
		super.onStop();
		RequestManager.cancelAll(this);
		TestinAgent.onStop(this);//此行必须放在super.onStop后
	}

	protected void executeRequest(Request<?> request) {
		RequestManager.addRequest(request, this);
	}

	protected Response.ErrorListener errorListener() {
		return new Response.ErrorListener() {
			@Override
			public void onErrorResponse(VolleyError error) {
				Toast.makeText(activity, error.getMessage(), Toast.LENGTH_LONG).show();
			}
		};
	}
	
	/**
	 * 父类初始化title
	 */
	public void initTitle(){
		     View findViewById = findViewById(R.id.title_root);
		     
		     if("http://182.92.111.126:8084/".equals(HttpUrls.switchs)){
		    	 findViewById.setBackgroundResource(R.drawable.main_group_bgdown_blue);
		     }
		     
			goBack = (Button)findViewById(R.id.title_back);
			titleRightBtn = (Button)findViewById(R.id.title_right);
			titleTextV = (TextView)findViewById(R.id.title_lable);
			titleRightBtn2 = (Button)findViewById(R.id.title_right2);
	}
}
